package com.aco.party.service.system;

import com.aco.party.dao.custom.${poNameC}Dao;
import com.aco.party.model.po.${poNameC};
import com.aco.party.model.vo.${poNameC}Vo;
import com.aco.party.model.vo.common.PageParam;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by flying on 3/10/2016 0010.
 */
@Service
public class ${poNameC}Service {
    @Resource
    private ${poNameC}Dao ${poName}Dao;

    public List<${poNameC}Vo> getByPage(PageParam pageParam) {
        List<${poNameC}Vo> list = new ArrayList<>();
        List<${poNameC}> ${poName}s = ${poName}Dao.getList(pageParam);
        ${poNameC}Vo vo;
        if (${poName}s != null) {
            for (${poNameC} ${poName} : ${poName}s) {
                vo = new ${poNameC}Vo();
                BeanUtils.copyProperties(${poName}, vo);
                list.add(vo);
            }
        }
        return list;
    }

    public Integer getTotal() {
        return ${poName}Dao.getTotal();
    }

    public void update(${poNameC} ${poName}) {
        ${poName}Dao.updateByPrimaryKeySelective(${poName});
    }

    public void add(${poNameC} ${poName}) {
        ${poName}Dao.insertSelective(${poName});
    }

    public void delete(Long id) {
        ${poName}Dao.deleteByPrimaryKey(id);
    }

    public ${poNameC} getByPrimaryKey(Long id) {
        return ${poName}Dao.selectByPrimaryKey(id);
    }
}
